//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 2021/06/27 17:47:16
// Design Name: 
// Module Name: MUX
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module MUX2 #(parameter width = 32)(
	input [width-1:0] d0,
	input [width-1:0] d1,
	input op,
	output reg [width-1:0] out
    );
	
	always @(*) begin
		case(op)
			0: out = d0;
			1: out = d1;
		endcase
	end
endmodule

module MUX4 #(parameter width = 32)(
	input [width-1:0] d0,
	input [width-1:0] d1,
	input [width-1:0] d2,
	input [width-1:0] d3,
	input [1:0] op,
	output reg [width-1:0] out
    );
	
	always @(*) begin
		case(op)
			0: out = d0;
			1: out = d1;
			2: out = d2;
			3: out = d3;
		endcase
	end
endmodule


module MUX8 #(parameter width = 32)(
	input [width-1:0] d0,
	input [width-1:0] d1,
	input [width-1:0] d2,
	input [width-1:0] d3,
	input [width-1:0] d4,
	input [width-1:0] d5,
	input [width-1:0] d6,
	input [width-1:0] d7,
	input [2:0] op,
	output reg [width-1:0] out
    );
	reg [2:0] n;
	always @(*) begin
		case(op)
			0: out = d0;
			1: out = d1;
			2: out = d2;
			3: out = d3;
			4: out = d4;
			5: out = d5;
			6: out = d6;
			7: out = d7;
		endcase
		//$display("d0:%d d1:%d d2:%d d3:%d d4:%d d5:%d d6:%d d7:%d WDSel:%d",d0,d1,d2,d3,d4,d5,d6,d7,op);
	end
endmodule
